use rpa_drive::DriverTrait;
use std::path::Path;

#[tokio::main]
async fn main() {
    std::env::set_var("log.level", "debug");
    std::env::set_var("driver.headless", "false");
    // std::env::set_var(
    //     "driver.remote_address",
    //     "http://127.0.0.1:4445,http://127.0.0.1:4444",
    // );
    use DriverTrait;

    /*for i in 0..5 {
        tokio::spawn(async move {
            let driver = rpa_drive::new(()).await.unwrap();
            driver.navigate_to("https://www.baidu.com/").await.unwrap();
            // let v = driver.get_value("div").await.unwrap();
            // println!("#est_switch: {}", v);
            driver
                .capture_screenshot("html", &Path::new(&format!("bot-async-{}.png", i)))
                .await
                .unwrap();
        });
    }*/
    let driver = rpa_drive::new(()).await.unwrap();
    driver.navigate_to("https://www.baidu.com/").await.unwrap();
    // let v = driver.get_value("div").await.unwrap();
    // println!("#est_switch: {}", v);
    driver
        .capture_screenshot("html", &Path::new(&format!("bot-async.png")))
        .await
        .unwrap();

    let _ = driver.close_tab_with_all().await;
    println!("drop-------1");
    drop(driver);
    println!("drop-------2");

    tokio::time::sleep(std::time::Duration::from_secs(10)).await;
    println!("-------3");
}
